package com.hellomeng.io;

import java.io.*;

//转换流
public class InputOutputWriterReader {

    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("TestData/readerFile.txt");
        FileOutputStream fos = new FileOutputStream("TestData/writeFileBB.txt");

        InputStreamReader reader = new InputStreamReader(fis,"UTF-8");
        //reader是从字节流 按照UDF-8编码方式 转换为的字符流

        OutputStreamWriter writer = new OutputStreamWriter(fos,"GBK");

        char[] chuf = new char[20];
        int len = reader.read(chuf);
        while (len != -1){
            writer.write(chuf,0,len);
        }

        reader.close();
        writer.close();
    }
}
